Adaptive histogram-based video contrast enhancement

ABSTRACT

The adaptive contrast enhancer uses an adaptive histogram equalization-based approach to improve contrast in a video signal. For each video frame, the histogram of the pixel luminance values is calculated. The calculated histogram is divided into three regions that are equalized independently of the other. The equalized values are averaged with the original pixel values with a weighting factor that depends on the shape of the histogram. The weighting factors can be also chosen differently for the three regions to enhance the darker regions more than the brighter ones. The statistics calculated from one frame are used to enhance the next frame such that frame buffers are not required. Many of the calculations are done in the inactive time between two frames.

FIELD OF THE INVENTION

The present invention relates generally to image and video processing, and more particularly to contrast enhancement.

BACKGROUND OF THE INVENTION

Contrast enhancement is used to improve the picture quality of digital video and is often implemented using video processors. Although many image processing techniques exist for contrast enhancement, they are often unsuitable for an ASIC implementation because of their computational complexity and/or storage requirements. Additionally, many image processing techniques might not work for video, because the picture is continuously changing and many algorithms may be prone to artifacts like contouring and saturation of gray levels.

Because contrast enhancement is usually performed in a color space that separates brightness information from color, most algorithms operate on data in formats such as YCbCr, HSV, and the like. For video applications, the YCbCr format is typically used because it is the industry standard for video transmission and storage. The YCbCr format is also typically easier to convert to and from RGB than from HSV. The ease in conversion is important because the final display is usually configured to accept data in RGB format.

An appreciation of the present invention and its improvements can be obtained by reference to the accompanying drawings, which are briefly summarized below, to the following detailed description of illustrated embodiments of the invention, and to the appended claims.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is an example pre-processing histogram of an image.

FIG. 2 is an example histogram of an image that has been equalized.

FIG. 3 is an example histogram of an image that has been divided into three regions in accordance with the present invention.

FIG. 4 illustrates example calculations of weighting factors in accordance with the present invention.

FIG. 5 is a block diagram of a contrast enhancer in accordance with the present invention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT

In the following detailed description of exemplary embodiments of the invention, reference is made to the accompanied drawings, which form a part hereof, and which is shown by way of illustration, specific exemplary embodiments of which the invention may be practiced. These embodiments are described in sufficient detail to enable those skilled in the art to practice the invention, and it is to be understood that other embodiments may be utilized, and other changes may be made, without departing from the spirit or scope of the present invention. The following detailed description is, therefore, not to be taken in a limiting sense, and the scope of the present invention is defined only by the appended claims.

Throughout the specification and claims, the following terms take the meanings explicitly associated herein, unless the context clearly dictates otherwise. The meaning of “a,” “an,” and “the” includes plural reference, the meaning of “in” includes “in” and “on.” The term “connected” means a direct electrical connection between the items connected, without any intermediate devices. The term “coupled” means either a direct electrical connection between the items connected, or an indirect connection through one or more passive or active intermediary devices. The term “circuit” means either a single component or a multiplicity of components, either active and/or passive, that are coupled together to provide a desired function. The term “signal” means at least one current, voltage, or data signal. Referring to the drawings, like numbers indicate like parts throughout the views.

The present invention is directed to adaptive contrast enhancement using an adaptive histogram equalization-based approach to improve contrast in a video signal. For each video frame, the histogram of the pixel luminance values is calculated. The calculated histogram is divided into three regions that are equalized independently of the other. The equalized values are averaged with the original pixel values with a weighting factor that depends on the shape of the histogram. The weighting factors can be also chosen differently for the three regions for example to enhance the darker regions more than the brighter ones, or vice-versa. The statistics calculated from one frame are used to enhance the next frame such that frame buffers are not required. Alternatively, if it is desired to use the same statistics from one frame to enhance the same frame, this can be achieved by simple insertion of a frame buffer stage between the generation of the statistics and the application of them. Many of the calculations are done in the inactive time between two frames.

Contrast enhancement is performed using the luminance or brightness part of the video signal. The YCbCr color space is typically used for contrast enhancement because the luminance and color information are separate and can be processed independently. The YCbCr color space is also one of the common video exchange formats that is currently used. “Y” is the luminance (usually referred to as luma) of the video while “Cb” and “Cr” are the chroma or color components. Another advantage of transmitting signals in YCbCr format is that the bandwidth of the signal can also be reduced by down-sampling the chrominance signals. Down-sampling is visually acceptable because the human vision system is typically more sensitive to brightness than to color. Y, Cb and Cr are usually assigned values ranging from 0 to 255 in an 8-bit system. When an offset of 128 is removed from Cb and Cr, the YCbCr space is referred to as the YUV space. In YUV space, U and V range from −128 to 127.

Data in RGB format can be converted to YUV using a set of linear equations such as:

$\begin{matrix} {\begin{pmatrix} Y \\ U \\ V \end{pmatrix} = {\begin{bmatrix} 0.299 & 0.587 & 0.114 \\ {- 0.172} & {- 0.339} & 0.511 \\ 0.511 & {- 0.428} & {- 0.083} \end{bmatrix}\begin{pmatrix} R \\ G \\ B \end{pmatrix}}} & (1) \end{matrix}$ where R, G, B and Y range from 0 to 255 while U and V range from −128 to 127. In the following example system, an 8-bit system is demonstrated.

The conversion coefficients in equation (1) are specified by the ITU-601 specification (SDTV) video standard. The inverse equation is used to convert YUV signals into an RGB format as follows:

$\begin{matrix} {\begin{pmatrix} R \\ G \\ B \end{pmatrix} = {\begin{bmatrix} 1 & 0 & 1.371 \\ 1 & {- 0.698} & {- 0.336} \\ 1 & 1.732 & 0 \end{bmatrix}\begin{pmatrix} Y \\ U \\ V \end{pmatrix}}} & (2) \end{matrix}$

FIG. 1 is an example pre-processing histogram of an image. Histogram equalization is an image processing technique that is used to improve picture contrast. Histograms of an image typically illustrate a count of the number of pixels of the image at each luma level. The x-axis (110) of the histogram 100 represents luma values that range from 0 to 255. The y-axis (120) is used to represent the number of pixels at each luma value. When the values on the y-axis are divided by the total number of pixels in the image, the values represent the probability or frequency of occurrence of each such luma value in that image. In the example histogram 100, the frequency of occurrence is shown as a probability density function (pdf). The histogram provides a wealth of information about the brightness properties of the image but spatial information is not ordinarily preserved. Thus images have an associated histogram, but histograms are not used to derive an image.

FIG. 2 is an example histogram of an image that has been equalized. Histogram equalization operates in accordance with the principle that images with good contrast typically have uniform histograms. (In practice, there may be exceptions.) Skewing histograms to low luma values (or concentrating the histograms within a particular range of luma values), the appearance of the image can be improved with contrast enhancement.

Histogram equalization attempts to “stretch” the histogram to improve the picture contrast. Comparing histogram 100 with histogram 200, it is evident that the stretching is performed more at the peaks of the histogram while compression is performed at the troughs of the histogram.

Mathematically, histogram equalization can be described as follows: Let n be the total number of pixels in the image and n_(k) be the number of pixels with luma value y_(k).

Then, probability density function (pdf) can be defined as

${f_{k}(y)} = \frac{n_{k}}{n}$ and cumulative density function (cdf) can be defined as

${F_{k}(y)} = {\sum\limits_{i = 0}^{i = k}{{f_{k}\left( y_{i} \right)}.}}$

An example cdf at any luma y_(k) represents the probability of a pixel having a luma value equal to or less than y_(k) in the image. The cdf is a non-decreasing function that varies from F_(k)(0) (the probability of points with luma value 0) to F_(k)(255)=1 (the probability of points with luma value being less than or equal to 255).

Where y_(min) is the lowest luma value present in an image and y_(max) is the highest present in the image, for every input pixel y_(in) the output y_(eq) can be given by Y _(eq) =Y _(min)+(y _(max) −y _(min))F _(k)(y _(in))  (3) Thus for every input pixel, Equation (3) gives a mapping to find the output in accordance with the cdf.

By itself, histogram equalization is not typically used in conventional contrast enhancement because it is prone to contouring, noise enhancement and gray level crushing. In an embodiment adaptive contrast enhancement scheme, the histogram is first divided into three equally spaced regions, corresponding to “shadows”, “mid-tones” and “highlights” in standard terminology used in photography, where the cdf of each region is found separately. FIG. 3 is an example histogram of an image that has been divided into three regions in accordance with the present invention.

The splitting of the histogram (300) into three regions facilitates processing each region independently of the other. Splitting the image into regions into a dark region (310), a mid-level brightness region (320), and a bright region (330) allows independent processing of the regions in accordance with the kind of region. For example, a greater level of enhancement is desired in the dark regions of the image to obtain a perceptually more pleasing image. Compared to the dark regions, the mid level regions and bright regions of the image are typically enhanced less. Dividing the histogram and treating each partition separately enables this functionality.

The output pixel is then found using the equation y _(out) =wƒ×y _(eq)+(1−wƒ)×y _(in)  (4) where y_(eq) can be calculated from equation (3) and y_(in) is the brightness of the original pixel. Equation (4) provides a weighted average between the original and equalized values for each pixel where wƒ is a weighting factor that can range from 0 to 1. The values y_(eq) and wƒ are typically calculated for each of the three regions independently. The blending process controls the level of contrast enhancement for each region.

As shown in equation (4), the weighting factors control the level of blending between equalized and original luma values, and thus control the level of enhancement. In the example contrast enhancement scheme, the weighting factors are calculated automatically using an approximate variance of the histogram (again separately by region). First the arithmetic mean of each region is calculated using

$\begin{matrix} {m_{i} = \frac{\sum\limits_{j}y_{j}}{N}} & (5) \end{matrix}$ where y_(j) represents luma of points in a particular region i and N is the total number of points in that region. The index i can be (for example) 0, 1 or 2 for dark, mid-level, and bright regions of the histogram.

Using the means, the variances of each region can be calculated using

$\begin{matrix} {\sigma_{i} = {\frac{1}{N}{\sum\limits_{j}{{n\left( y_{j} \right)}\left( {{y_{j} - m_{i}}} \right)}}}} & (6) \end{matrix}$ where n(y_(j)) is a count of the number of pixels of luma y_(j) and σ_(i) is the variance of the ith region. The summation is typically carried out only for points of a single region to get the variance of that region. In the example equation, σ_(i) is an approximation of the true variance. Calculating a more exact variance involves more multipliers and a square root operation (which is computationally intensive and/or requires a significant amount of circuitry to implement). Using the approximate variance shown above produces visually appealing results while reducing hardware requirements (over calculating a more exact variance).

FIG. 4 illustrates example calculations of weighting factors in accordance with the present invention. The weighting factors can be calculated (after the variances have been calculated) using an example relationship as shown in FIG. 4. The weighting factor curve (400) can be chosen in accordance with the following factors. First, the variance is shown as being limited to a value between 0 and 42 such that the width of each partition of the histogram is 84 (255 integer-divided by 3). The variance is lower when the histogram is concentrated within smaller ranges. When the histogram is concentrated within smaller ranges, a low weighting factor is used because an image with a concentrated histogram is susceptible to contouring.

The variance is higher, for example, when the histogram has two peaks at each extremity of the partition. For this case, contrast enhancement is not as beneficial and hence a low weighting factor is typically used. For other shapes of the histogram, the variance would range between 0 and 42 and the triangular shape curve is chosen. The level of enhancement is usually highest for a histogram having a mid-level variance and that tapers off in a linear fashion on both sides. Using a shape-based weighting of contrast enhancement helps to reduce artifacts such as contouring in the output image and changes the level of enhancement that is optimized for a particular image.

The peak of the triangularly shaped weighting factor curve 410 in FIG. 4 is different for each partition of histogram. Weighting factor curve 410 provides another control over the level of enhancement depending on the region of the image. For darker regions the curve is higher, which provides more enhancement in the darker regions of the image. The mid luma and bright regions of the image are enhanced to a lesser degree.

FIG. 5 is a block diagram of a contrast enhancer in accordance with the present invention. Contrast enhancer 500 comprises equalizer 510, histogram updater 520, weighting factor calculator 530, and previous frame histogram memory 540. In operation, an input YUV data stream is supplied to equalizer 510 as well as to histogram updater 520. A histogram for each region (in the example, one each of three regions) of an image frame is stored in a 256 word SRAM.

Along with the histogram, counters with number of points and luma sums are updated for each of the three regions, which are then used to calculate the mean of each region. Because processes are done on the live frame, the pdf is ordinarily not calculated. The pdf is not calculated because the pdf is derived using a division at each histogram location. Calculating the pdf is computationally intensive so typically the histogram and cumulative histogram are computed without calculating the pdf.

The histogram updating is typically completed at the end of the live frame. During the blanking interval, the means are calculated and the cumulative sum of the histogram performed. The accumulation can be done by reading the histogram value from each memory location and replacing it with the cumulative value. At the end of each region, the accumulation is typically reset. Along with the cumulative sum, the values read from the histogram are used to accumulate and calculate the variances using equation (6). Once the variances are calculated, the weighting factors are calculated and sent to the equalizer 510. The reciprocal of the number of points in each region is used to calculate the mean and variance and also sent to equalizer 510.

In equalizer 510, the output is calculated as in equation (3) using the input luma, weighting factors, reciprocal of the number of points and cumulative histogram, which has been stored from the previous frame in memory. The cdf is obtained from the cumulative histogram using the reciprocals of the number of points for division. Thus the statistics of the previous frame can be used to enhance the current frame. However since the cdf of the previous frame is required to process the current one, the histogram of the current frame is stored in another memory. Thus two memories are used and can be alternated between holding the current histogram and previous cumulative histogram.

In an alternate embodiment, the two memories can be used and alternated between holding the current histogram and previous cumulative histogram on a real-time basis where statistics from same frame are used upon on the same frame (as compared to being used on the next frame). The structure can remain the same with the two memories, with the difference that the statistics generation is now operating on the frame that is being written to frame buffer, while the enhancement is using the stored statistics and being applied to the previous frame that is being read out of the frame buffer.

An adaptive contrast enhancement scheme for digital video is described herein. An example method uses a histogram equalization based method that works by dividing the histogram into three equal partitions, calculating the equalization parameters for each of them independently, and then blending the equalized luma values with the original ones. The histogram shape of each region controls this blending.

The level of enhancement can also be varied for different regions. By controlling the enhancement based on the histogram shape, the method reduces contouring in images that have sharp peaks in their histograms. By controlling the enhancement based on luma, the method can enhance darker regions more than brighter ones, which leads to perceptually better images than traditional histogram equalization based schemes.

The method is also relatively easy to implement in digital logic. The only storage required is a memory to store histograms because the enhancement is applied to each video frame based upon the previous one. Many calculations that are done during inactive signal time can also be optimized for area reduction for implementation logic circuitry.

Various embodiments of the invention are possible without departing from the spirit and scope of the invention. The above specification, examples and data provide a complete description of the manufacture and use of the composition of the invention. For example, the architecture can be implemented using hardware, software, or a combination of both. Since many embodiments of the invention can be made without departing from the spirit and scope of the invention, the invention resides in the claims hereinafter appended. 

1. A method for processing a video signal, comprising: deriving a histogram of a received signal of an image using a histogram updater, wherein the histogram comprises pixel luminance information associated with pixels in the image, and wherein the histogram defines a range of luminance values; processing the histogram with an equalizer by: dividing the histogram into regions corresponding to pre-determined sub-ranges of the defined range of luminance values, wherein each region comprises a portion of the pixel luminance information; and equalizing each region to provide equalized pixel luminance values, wherein a given region is equalized based on a cumulative density function that calculates a probability of a pixel in the given region having a luminance value equal to or less than a given luminance value; calculating a mean luminance value for each region, wherein the mean luminance value of each respective region depends only on the portion of the pixel luminance information associated with that region; calculating a weighting factor for each region based on the mean luminance value of that region using a weighting factor calculator; and providing output pixel luminance values, with the equalizer, based on a weighted average of the pixel luminance information and the equalized pixel luminance values in accordance with each of the weighting factors.
 2. The method of claim 1, wherein the weighting factor of a first region differs from the weighting factor of a second region.
 3. The method of claim 1, wherein the weighting factor is calculated for each region in accordance with a shape of the histogram.
 4. The method of claim 1, wherein the weighting factor is calculated for each region based on a weighting factor curve that relates histogram variance values to weighting factor values.
 5. The method of claim 1, wherein the cumulative density function is determined separately for each region.
 6. The method of claim 1, wherein the weighting factor is calculated for each region in accordance with the equation: ${\sigma_{i} = {\frac{1}{N}{\sum\limits_{j}{{n\left( y_{j} \right)}\left( {{y_{j} - m_{i}}} \right)}}}},$ where ${m_{i} = \frac{\sum\limits_{j}y_{j}}{N}},$ where y_(j) represents luma of points in a region i, N is a total number of points in the region i, n(y_(j)) is a count of a number of pixels of luma y_(j), and σ_(i) is a variance of the region i.
 7. The method of claim 1, wherein the method is performed in a period of time that is around a blanking interval between two successive image frames in the received signal.
 8. The method of claim 1, wherein the method is performed on a real-time basis.
 9. A contrast enhancement system, comprising: means for deriving a histogram of a received signal of an image, wherein the histogram comprises pixel luminance information associated with pixels in the image, and wherein the histogram defines a range of luminance values; means for dividing the histogram into regions corresponding to pre-determined sub-ranges of the defined range of luminance values, wherein each region comprises a portion of the pixel luminance information; means for equalizing each region to provide equalized pixel luminance values, wherein a given region is equalized based on a cumulative density function that calculates a probability of a pixel in the given region having a luminance value equal to or less than a given luminance value; means for calculating a mean luminance value for each region, wherein the mean luminance value of each respective region depends only on the portion of the pixel luminance information associated with that region; means for calculating a weighting factor for each region based on the mean luminance value of that region; and means for providing output pixel luminance values based on a weighted average of the pixel luminance information and the equalized pixel luminance values in accordance with each of the weighting factors.
 10. The system of claim 9, wherein the weighting factor of a first region differs from the weighting factor of a second region.
 11. The system of claim 9, wherein the means for calculating the weighting factor for each region calculates the weighting factor for each region in accordance with a shape of the histogram.
 12. The system of claim 9, wherein the means for equalizing each region comprises means for determining the cumulative density function separately for each region.
 13. The system of claim 9, wherein the means for equalizing each region equalizes each region in a period of time that is around a blanking interval between two successive image frames in the received signal.
 14. The method of claim 1, wherein each of the pre-determined sub-ranges contains a substantially equal number of luminance values.
 15. The method of claim 4, wherein each region is associated with its own weighting factor curve, and wherein the weighting factor of each respective region is calculated based on the weighting factor curve of that region.
 16. The system of claim 9, wherein each of the pre-determined sub-ranges contains a substantially equal number of luminance values.
 17. The system of claim 9, wherein the means for calculating the weighting factor for each region calculates the weighting factor for each region based on a weighting factor curve that relates histogram variance values to weighting factor values.
 18. The system of claim 17, wherein each region is associated with its own weighting factor curve, and wherein the means for calculating the weighting factor for each region calculates the weighting factor of each respective region based on the weighting factor curve of that region. 